<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">		
		<title>注册</title>
		<link rel="stylesheet" href="css/lqbase.css" />
		<link rel="stylesheet" href="css/lqpublic.css" />
		<script src="js/jquery-1.10.1.min.js"></script>
		<!-- <script scr="js/common.js"></script> -->
			
	</head>
	<body class="paddbottom backgry">
		<form name="registerform" action="" onsubmit="register()" method="get">
		<div class="register">
				<div class="userdiv">
					<p class="userp2"><label>手机号</label><input type="text" name="phone" id="phone" placeholder="请输入账号" value=""> </p>
					<p class="userp2"><label>设置密码</label><input type="text" name="mima" id="mima" placeholder="请输入账号" value=""> </p>
					<p class="userp2"><label>邀请人手机号</label><input type="text" name="yphone" id="yphone" placeholder="请输入账号" value=""> </p>
				</div>

			</div>
			<!-- submit -->
			<input class="bluebtn" type="submit" value="注册"></input>
			<div class="tiaok">
			<label class="taiokcenter"><input type="checkbox" name="gou" id="gou"><i class="gou"></i>同意<a class="bluefont" href="xieyi3.html">《浦新金服网站服务协议》</a>及<a class="bluefont" href="xieyi1.html">《隐私条款》</a></label>

			</div>
			
		</form>

<script type="text/javascript">
				
				// 提交表单
				function register(){	
					var ophone = $('#phone').val();//手机号
					var omima = $('#mima').val();//密码
					var oyphone = $('#yphone').val();//邀请人手机号
					var regu = /^[1][0-9][0-9]{9}$/; /*判断手机格式是否正确*/	
					var re = new RegExp(regu);

					// 验证为空，格式正确
					if (ophone.length!=0 && re.test(ophone) && omima.length!=0 && oyphone.length!=0 && re.test(oyphone) && $('#gou').is(":checked")) {
						console.log("提交表单");
					$.ajax({
						type:'get',
						async:false,
						url : 'https://xiaochengxu.itenez.com/pxjfoption/front/login/registerUser',
						dataType : "jsonp",//数据类型为jsonps
                		jsonp: "jsonpCallback",//服务端用于接收callback调用的function名的参数,
                		data:{
                			'tel':ophone,
                			'oldpassword':omima,
                			'invitationTel':oyphone
                		},
                		success:function(res){
                			if(res.status==200 || res.status=='200'){
                				console.log('提交成功 ');
                			}else if(res.status==205 || res.status=='205'){
                				console.log('邀请电话不存在');
                			}else if(res.status==204 || res.status=='204'){
                				console.log('用户已存在');
                			}else if(res.status==201 || res.status=='201'){
                				console.log('系统异常');
                			}

                		}
					});
					}else{
						if(ophone.length==0){
						alert('请输入手机号');
						return
						}
						if(re.test(ophone)==false){
							alert("请输入正确手机号");
							return
						}if(re.test(oyphone)==false){
							alert("请输入正确邀请人手机号");
							return
						}
						if(omima.length==0){
							alert('请输入密码');
							return
						}
						if(oyphone.length==0){
							alert('请输入邀请人手机号');
							return
						}
						  if($("#gou").is(":checked")==false){
			            	alert("请勾选阅读按钮");
			            	return
			            }
					}

				}
			</script>
				
	</body>
</html>
